package com.ruijie.autotest.log.validation.hangzhoudewangxin.IMDEV;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.ruijie.autotest.log.core.validate.IValidator;
import com.ruijie.autotest.log.impl.validate.SolidValueValidator;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

import static com.ruijie.autotest.log.impl.validate.SqlExistingValidator.sqlExistingVerificationOf;

@SpringBootConfiguration
public class Config {
	@Bean
	public DataSource dataSource() {
		return new ComboPooledDataSource("remote");
	}

	@Bean
	public IValidator locationCodeValidator(DataSource dataSource) {
		return sqlExistingVerificationOf("s_location.code", dataSource);
	}

	@Bean
	public IValidator typeValidator(DataSource dataSource) {
		return sqlExistingVerificationOf("s_device.type", dataSource);
	}

	@Bean
	public IValidator macCodeValidator(DataSource dataSource) {
		return sqlExistingVerificationOf("s_device.mac", dataSource);
	}

	@Bean
	public IValidator deviceCodeValidator(DataSource dataSource) {
		return sqlExistingVerificationOf("s_device.code", dataSource);
	}

	@Bean
	public IValidator deviceNameValidator(DataSource dataSource) {
		return sqlExistingVerificationOf("s_device.name", dataSource);
	}

	@Bean
	public IValidator addressValidator(DataSource dataSource) {
		return sqlExistingVerificationOf("s_location.streets", dataSource);
	}

	@Bean
	public IValidator childTypeValidator(DataSource dataSource) {
		return sqlExistingVerificationOf("s_security_org.org_code", dataSource);
	}

	@Bean
	public IValidator sourceValidator(DataSource dataSource) {
		return sqlExistingVerificationOf("s_security_org.org_code", dataSource);
	}

	@Bean
	public IValidator longitudeValidator(DataSource dataSource) {
		return sqlExistingVerificationOf("s_location.longitude", dataSource);
	}

	@Bean
	public IValidator latitudeValidator(DataSource dataSource) {
		return sqlExistingVerificationOf("s_location.latitude", dataSource);
	}

	@Bean
	public IValidator uploadTimeIntervalValidator() {
		return new SolidValueValidator("100");
	}

	@Bean
	public IValidator collectionRadiusValidator() {
		return new SolidValueValidator("100");
	}

	@Bean
	public IValidator floorValidator(DataSource dataSource) {
		return sqlExistingVerificationOf("s_device.floor", dataSource);
	}

	@Bean
	public IValidator subwayStationValidator() {
		return new SolidValueValidator("");
	}

	@Bean
	public IValidator subwayLineInfoValidator() {
		return new SolidValueValidator("");
	}

	@Bean
	public IValidator subwayVehicleInfoValidator() {
		return new SolidValueValidator("");
	}

	@Bean
	public IValidator subwayCompartmentNumberValidator() {
		return new SolidValueValidator("");
	}

	@Bean
	public IValidator carCodeValidator() {
		return new SolidValueValidator("");
	}

	@Bean
	public IValidator qrCodeValidator() {
		return new SolidValueValidator(" ");
	}
}
